package com.ideal.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: lilei
 * @Description: 日期工具类
 * @date: 2022/7/15
 */
public class DateUtils {


    /**
     * 日期格式化
     *
     * @param date
     * @param format
     * @return
     */
    public static String formatDate(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);

    }

    public static Date toDate(String time, String format) throws ParseException {
        return new SimpleDateFormat(format).parse(time);
    }

}
